 using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
//test chang :D
namespace Medival_Snake
{

    class Objects
    {
        public bool SightLeft = false;
        public bool SightRight = false;
        public bool SightDown = false;
        public bool SightUp = false;

        public Vector2 Position;
        public Texture2D Texture;
        public Rectangle Sensor;
        public Vector2 Move = Vector2.Zero;
        Vector2 BaseMove = Vector2.Zero;
        string name;

        public Objects(Vector2 pos,Texture2D tex,string name = "")
        {
            this.Position = pos;
            this.Texture = tex;
            this.name = name;
            Standalizer();

        }

        public void SetPos(Vector2 newPos)
        {
            Position = newPos;
        }

        public void Standalizer()
        {
            switch (name)
            {
                case "orc":
                    BaseMove = new Vector2(.5f, .5f);
                    break;
            }
        }

        public void ResetMove() { Move = BaseMove; }

        public void SetBaseMove(float x, float y)
        {
            this.BaseMove.X = x;
            this.BaseMove.Y = y;
        }

        public Rectangle Getbounds()
        {
            return new Rectangle((int)Position.X, (int)Position.Y, Texture.Width, Texture.Height);

        }
        public Rectangle SightBounds()
        {

            if (SightDown)
            {
                return new Rectangle((int)Position.X, (int)Position.Y + Texture.Height, Texture.Width, Texture.Height * 3);
            }
            if (SightLeft)
            {
                return new Rectangle((int)Position.X - Texture.Width * 3, (int)Position.Y, Texture.Width * 3, Texture.Height);
            }
            if (SightRight)
            {
                return new Rectangle((int)Position.X + Texture.Width, (int)Position.Y, Texture.Width * 3, Texture.Height);
            }
            if (SightUp)
            {
                return new Rectangle((int)Position.X, (int)Position.Y - Texture.Height * 3, Texture.Width, Texture.Height * 3);
            }
            else
                return new Rectangle((int)Position.X, (int)Position.Y, Texture.Width, Texture.Height);
        }

        public void Update()
        {
             Sensor = new Rectangle((int)Position.X,(int)Position.Y,Texture.Width,Texture.Height);
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(Texture, Getbounds(), Color.White);
        }
    }
}
